package com.yyfax.pay.third.model.to.fuiou.xml;

import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.yyfax.framework.model.Content;
import com.yyfax.pay.third.model.to.fuiou.PayOrderFuiouContent;

@XStreamAlias("qrytransrsp")
public class QueryPayoutOrderFuiouContent extends Content{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1985250318088264L;

	private String ret;
	
	private String memo;
	
	private List<QueryTransContent> trans;
	
	@JsonIgnore
	private String reqContent;

	public String getReqContent() {
		return reqContent;
	}

	public void setReqContent(String reqContent) {
		this.reqContent = reqContent;
	}

	public String getRet() {
		return ret;
	}

	public void setRet(String ret) {
		this.ret = ret;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public List<QueryTransContent> getTrans() {
		return trans;
	}

	public void setTrans(List<QueryTransContent> trans) {
		this.trans = trans;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}
	/**
	 * 该实体转换成XML字符串
	 * 
	 * @author heizq
	 * @date 2017-4-12 10:52:52
	 * @since v1.0.0
	 * @return 返回XML字符串
	 */
	public String toXml() {
		QNameMap qmap = new QNameMap();
		qmap.setDefaultPrefix("");
		StaxDriver staxDriver = new StaxDriver(qmap);
		XStream xstream = new XStream(staxDriver);
		xstream.autodetectAnnotations(true);
		xstream.ignoreUnknownElements();
		return xstream.toXML(this);
	}

	/**
	 * XML字符串转换成实体{@link PayOrderFuiouContent}
	 * 
	 * @author heizq
	 * @date 2017-4-12 10:53:28
	 * @since v1.0.0
	 * @param xml
	 * @return 返回{@link PayOrderFuiouContent}
	 */
	public static QueryPayoutOrderFuiouContent fromXml(String xml) {
		QNameMap qmap = new QNameMap();
		qmap.setDefaultPrefix("");
		StaxDriver staxDriver = new StaxDriver(qmap);
		XStream xstream = new XStream(staxDriver);
		xstream.autodetectAnnotations(true);
		xstream.ignoreUnknownElements();
		xstream.alias("qrytransrsp", QueryPayoutOrderFuiouContent.class);
        xstream.alias("trans", QueryTransContent.class);  
        xstream.addImplicitCollection(QueryPayoutOrderFuiouContent.class, "trans");

		return (QueryPayoutOrderFuiouContent) xstream.fromXML(xml);
	}
	
	public static void main(String[] args) {
		String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?> <qrytransrsp> <ret>000000</ret> <memo>成功</memo> <trans> <merdt>20110417</merdt> <orderno>20110417000001</orderno> <accntno>1111111111111111111</accntno> <accntnm>张三</accntnm> <amt>100000</amt> <state>1</state></trans><trans> <merdt>20110417</merdt> <orderno>20110417000001</orderno> <accntno>1111111111111111111</accntno> <accntnm>张三</accntnm> <amt>100000</amt><state>1</state></trans></qrytransrsp>";
		System.out.println(QueryPayoutOrderFuiouContent.fromXml(xml).toXml());
	}
	
}
